<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加品牌</title>
</head>
<body>
<div id="app">
    <h3>添加品牌</h3>
    <form action="" method="post">
        品牌名称：<input id="brandName" name="brandName" v-model="brand.brandName"><br>
        企业名称：<input id="companyName" name="companyName" v-model="brand.companyName"><br>
        排序：<input id="ordered" name="ordered " v-model="brand.ordered"><br>
        描述信息：<textarea rows="5" cols="20" id="description" name="description" v-model="brand.description"></textarea><br>
        状态：
        <input type="radio" name="status" value="0" v-model="brand.status">禁用
        <input type="radio" name="status" value="1" v-model="brand.status">启用<br>

        <input type="button" id="btn" @click="DataForm" value="提交">
    </form>
</div>
<script src="js/axios-0.18.0.js"></script>
<script src="js/vue.js"></script>
<script>
    //设置一个forData json对象
    new Vue({
        el:"#app",
        data() {
            return{
                brand:{}
            }
        },
       methods:{
            DataForm(){
                var _this=this;
                axios({
                            method:"post",
                            url:"http://localhost:8084/test-demo/addServlet",
                            data:_this.brand
                        }).then(function (resp) {
                              if ("success"==resp.data){
                                  //如果成功，进入bran.html页面
                                  location.href="http://localhost:8084/test-demo/brand.html"
                              }

                        })
            }
       }
    })

    // document.getElementById("btn").onclick=function () {
    //     var formData={
    //         brandName:"",
    //         companyName:"",
    //         ordered:"",
    //         description:"",
    //         status:"",
    //     };
    //
    //     //接收表单数据
    //     let brandName = document.getElementById("brandName").value;
    //     //传给forData
    //     formData.brandName=brandName;
    //     let companyName = document.getElementById("companyName").value;
    //     formData.companyName=companyName;
    //     let ordered = document.getElementById("ordered").value;
    //     formData.ordered=ordered;
    //     let description = document.getElementById("description").value;
    //     formData.description=description;
    //     let status = document.getElementsByName("status");
    //     for(let i=0;i<status.length;i++){
    //         if(status[i].checked){
    //             formData.status=status[i].value;
    //         }
    //     }
    //     axios({
    //         method:"post",
    //         url:"http://localhost:8084/test-demo/addServlet",
    //         data:formData
    //     }).then(function (resp) {
    //           if ("success"==resp.data){
    //               //如果成功，进入bran.html页面
    //               location.href="http://localhost:8084/test-demo/brand.html"
    //           }
    //
    //     })
    //
    // }
</script>


</body>
</html>